package com.hq.ims.data.vo;

import com.hq.ims.data.entity.CompanyDepartmentEmployee;
import com.hq.utils.util.ListUtils;
import com.hq.utils.util.StringUtils;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20240929
 */
@Mapper
public interface CompanyDepartmentEmployeeMapstruct {

    //CompanyDepartmentEmployeeMapstruct INSTANCE = Mappers.getMapper(CompanyDepartmentEmployeeMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    CompanyDepartmentEmployeeVo toCompanyDepartmentEmployeeVo(CompanyDepartmentEmployee source);

    default List<CompanyDepartmentEmployeeVo> toCompanyDepartmentEmployeeVoList(List<CompanyDepartmentEmployee> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toCompanyDepartmentEmployeeVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class CompanyDepartmentEmployeeVo extends CompanyDepartmentEmployee {

    }

    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

        @NotBlank(message = "公司部门ID")
        private String companyDepartmentId;

        @NotBlank(message = "用户姓名")
        private String realName;

    }


    @ApiModel(value = "绑定用户权限")
    @Data
    class MoveUserVo {

        @NotBlank(message = "移动到哪个部门")
        private String toDepartmentId;

        @NotEmpty(message = "需要移动的用户详情")
        @Valid
        private List<MoveUserDetailVo> moveUserDetailVoList;

        private String jobName = StringUtils.EMPTY;

    }

    @ApiModel(value = "移动用户到其它部门")
    @Data
    class MoveUserDetailVo {

        @NotBlank(message = "当前用户ID不能为空")
        private String userId;

        @NotBlank(message = "当前用户部门ID不能为空")
        private String companyDepartmentId;

    }


    //-------------------------------- springboot验证标识 --------------------------------

}
